package com.gxa.controller.basic_commodity_settings;

import com.gxa.common.Constants;
import com.gxa.common.PaginationResult;
import com.gxa.common.ResponseData;
import com.gxa.pojo.Lacost;
import com.gxa.pojo.StoneHead;
import com.gxa.service.WslcmService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: zxy
 * Date: 2020/10/28 11:35
 * Description:
 * Version: V1.0
 */
@RestController
@RequestMapping("laborcost")
@Api(value = "批发销售工费管理",tags = "批发销售工费管理")
public class WslcmController {

    @Autowired
    private WslcmService wslcmService;

    @Autowired
    private ResponseData responseData;

    /**
     * 批发销售工费管理
     * @return
     */
    @GetMapping(value = "/queryLacost")
    @ApiOperation(value = "查询批发销售工费管理",notes = "查询对应的批发销售工费管理",httpMethod = "get", response = ResponseData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="查询成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData queryLacost(@RequestParam(defaultValue = "1") int currentPage, @RequestParam(defaultValue = "3")int pageSize){
        PaginationResult paginationResult = wslcmService.queryLacost(currentPage,pageSize);
        if(paginationResult != null){
            responseData.setCode(Constants.SUCCESS);
            responseData.setMsg("查询成功");
            responseData.setData(paginationResult);
        }
        return responseData;
    }

    @PostMapping(value = "/updateLacost")
    @ApiOperation(value = "修改批发销售工费管理",notes = "根据返回的值修改对应的批发销售工费管理信息",httpMethod = "Post", response = ResponseData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="修改成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData updateLacost(@RequestBody @ApiParam(name = "lacost",value = "批发销售工费管理") Lacost lacost){
        int result = wslcmService.updateLacost(lacost);
        if(result > 0){
            responseData.setCode(Constants.SUCCESS);
            responseData.setMsg("修改成功");
            responseData.setData(lacost);
        }
        return responseData;
    }

    @PostMapping(value = "/delLacost")
    @ApiOperation(value = "删除批发销售工费管理",notes = "根据页面返回的值删除对应的批发销售工费管理信息",httpMethod = "Post", response = ResponseData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="删除成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData delLacost(@RequestBody @ApiParam(name = "lacostId",value = "批发销售工费管理id") Lacost lacost){
        int result = wslcmService.delLacost(lacost.getLacostId());
        if(result > 0){
            responseData.setCode(Constants.SUCCESS);
            responseData.setMsg("删除成功");
        }
        return responseData;
    }

    @PostMapping(value = "/addLacost")
    @ApiOperation(value = "添加批发销售工费管理",notes = "根据页面返回的值添加对应的批发销售工费管理信息",httpMethod = "Post", response = ResponseData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="添加成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData addLacost(@RequestBody @ApiParam(name = "lacost",value = "批发销售工费管理") Lacost lacost){
        int result = wslcmService.addLacost(lacost);
        if(result > 0){
            responseData.setCode(Constants.SUCCESS);
            responseData.setMsg("添加成功");
            responseData.setData(lacost);
        }
        return responseData;
    }
}
